package Basic.day02;

public class DoubleDemo {
    public static void main(String[] args) {
        long d = 5;
        double e = d;
        System.out.println(d);
        System.out.println(e);
        System.out.println(d == e);//输出true

        long f = 52000000000000L;
        int g = (int) f;
        System.out.println(g); //溢出

        double h = 5.1;
        int i = (int) h;
        System.out.println(i);//输出5，丢失精度

        int num1 = 10;
        long num2 = (long) num1; // 将int类型转换为long类型

        byte b4 = 5;
        byte b5 = 6;
//        byte b6 = b4+ b5; // 编译错误，不能把两个byte相加
        byte b6 = (byte) (b4+ b5); //强转为byte则可以通过
        System.out.println(b6);
        int b7 = b4+ b5; //  自动类型转换，byte自动转换为int，所以用int接收
        System.out.println(b7);

        System.out.println(2+2);//4
        System.out.println(2+'2');//52,2加上'2'的ASCII码50
        System.out.println('2'+'2');//100，'2'的ASCII码50加上'2'的ASCII码50
        System.out.println('2');//2
    }
}
